package com.czxy.dao;

import com.czxy.pojo.Specification;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 规格Mapper
 * @author Liuyunqin 17674029449@163.com
 * @date 2018/12/25 14:50
 */
@org.apache.ibatis.annotations.Mapper
public interface SpecificationMapper extends Mapper<Specification> {
    /**
     * 查询 三级分类下 所有的规格
     * 比如 手机分类id是76
     * @return
     */
    @Select("SELECT * FROM tb_specification WHERE category_id=#{catId}")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "spec_name",column = "spec_name"),
            @Result(property = "category_id",column = "category_id"),
            @Result(property = "options",column = "id",one = @One(select = "com.czxy.dao.SpecificationOptionMapper.findSpecificationOptionBySpecId")),
    })
    public List<Specification> findSpecofocationByCatId(@Param("catId") Integer catId);
}
